package com.xh.shuati.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xh.shuati.model.dto.post.PostQueryRequest;
import com.xh.shuati.model.dto.question.QuestionQueryRequest;
import com.xh.shuati.model.entity.Post;
import com.xh.shuati.model.entity.Question;
import com.xh.shuati.model.entity.User;
import com.xh.shuati.model.vo.QuestionVO;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 题目服务
 *
 * @author <a href="https://github.com/canon0521">xh</a>
 */
public interface QuestionService extends IService<Question> {


    /**
     * 根据ID删除题目
     * @param quesiton
     * @return
     */
    boolean deleteQuestionById(Question quesiton);

    /**
     * 根据题目ID获取题目封装
     * @param id
     * @return
     */
    Question getQuestionById(Long id);


    /**
     * 校验数据
     *
     * @param question
     * @param add      对创建的数据进行校验
     */
    void validQuestion(Question question, boolean add);

    /**
     * 获取查询条件
     *
     * @param questionQueryRequest
     * @return
     */
    QueryWrapper<Question> getQueryWrapper(QuestionQueryRequest questionQueryRequest);

    /**
     * 获取题目封装
     *
     * @param question
     * @return
     */
    QuestionVO getQuestionVO(Question question);

    /**
     * 分页获取题目封装
     *
     * @param questionPage
     * @param request
     * @return
     */
    Page<QuestionVO> getQuestionVOPage(Page<Question> questionPage, HttpServletRequest request);

    /**
     * 从缓存中获取题目
     * @return
     */
    Page<QuestionVO> getQuestionFromCache(QuestionQueryRequest request);

    /**
     * 分页获取题目列表（仅管理员可用）
     *
     * @param questionQueryRequest
     * @return
     */
    Page<Question> listQuestionByPage(QuestionQueryRequest questionQueryRequest);

    /**
     * 从 ES 查询
     *
     * @param questionQueryRequest
     * @return
     */
    Page<Question> searchFromEs(QuestionQueryRequest questionQueryRequest);

    /**
     * 批量删除
     *
     * @param questionids
     */
    void batchDeleQuestions(List<Long> questionids);

    /**
     * AI 添加题目
     * @param quetionType
     * @param number
     * @param user
     */
    boolean aiGenerateQuestions(String quetionType,Integer number, User user);


}
